package com.zhm.demo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.net.URISyntaxException;

@Slf4j
//@Component
public class TestComponent2 implements ApplicationContextAware {

    ApplicationContext applicationContext;


    @PostConstruct
    public void init() throws URISyntaxException {
//        new Thread(() -> {
//            while (true) {
//                try {
//                    TestBean bean = applicationContext.getBean(TestBean.class);
//                    System.out.println(bean);
//                    Thread.sleep(1000);
//                } catch (Exception e) {
//                    log.error("", e);
//                }
//            }
//        }).start();


    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
